package org.coco24.pmstudio.util

import com.badlogic.gdx.scenes.scene2d.ui.Table
import com.kotcrab.vis.ui.building.TableBuilder

class LeftTableBuilder: TableBuilder()
{
    override fun fillTable(table: Table?)
    {
        val rowSizes = rowSizes
        val widgetsInRow = TableBuilder.getLowestCommonMultiple(rowSizes)
        var rowIndex = 0
        var widgetIndex = 0
        while (rowIndex < rowSizes.size)
        {
            val rowSize = rowSizes.get(rowIndex)
            val currentWidgetColspan = widgetsInRow / rowSize
            val totalWidgets = widgetIndex + rowSize
            while (widgetIndex < totalWidgets)
            {
                getWidget(widgetIndex).buildCell(table, defaultWidgetPadding).left().colspan(
                        currentWidgetColspan)
                widgetIndex++
            }
            table?.row()
            rowIndex++
        }
    }
}